<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 *
 */
$styleSheet = "orange";

$GLOBALS['lang_Common_SortAscending'] = $lang_Common_SortAscending;
$GLOBALS['lang_Common_SortDescending'] = $lang_Common_SortDescending;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../../themes/<?php echo $styleSheet; ?>/css/style.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 6]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE6_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<!--[if IE]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<script type="text/javascript" src="../../themes/<?php echo $styleSheet;?>/scripts/style.js"></script>
<link type="text/css" rel="stylesheet" href="/themes/orange/css/yui/calendar/assets/calendar.css" />
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="../../scripts/octopus.js"></script>
<script type="text/javascript" src="../../scripts/common.js"></script>
<script type="text/javascript" src="../../scripts/jquery/jquery.js"></script>
<script type="text/javascript" src="../../scripts/yui/yahoo/yahoo-min.js"></script>
<script type="text/javascript" src="../../scripts/yui/event/event-min.js" ></script>
<script type="text/javascript" src="../../scripts/yui/dom/dom-min.js" ></script>

<script type="text/javascript" src="../../scripts/yui/container/container-min.js"></script>
<script type="text/javascript" src="../../scripts/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="../../scripts/yui/element/element-beta-min.js"></script>

<script type="text/javascript" src="../../scripts/yui/calendar/calendar.js"></script>
<script type="text/javascript" src="../../scripts/yui/button/button-beta-min.js"></script>

<script type="text/javascript" src="../../scripts/yui/animation/animation-min.js"></script>
<script type="text/javascript" src="../../scripts/yui/autocomplete/autocomplete-min.js"></script>
<script type="text/javascript" src="../../scripts/time.js"></script>

<script type="text/javascript" src="../../scripts/calendar/calendar.js"></script>
<script type="text/javascript">
YAHOO.namespace("OrangeHRM.time");

YAHOO.OrangeHRM.calendar.format = 'yyyy-MM-dd';
YAHOO.OrangeHRM.calendar.formatHint.format = '';
YAHOO.OrangeHRM.time.format = 'HH:mm';
	function add() {

	/*var cnt = document.GoodsRecord.EmpId;
	if(!(cnt.value == '') && !alpha(cnt) && !confirm('员工id不能为空')) {
		cnt.focus();
		return;
	}  if (cnt.value == '') {
		alert('<?php echo $lang_Error_LastNameEmpty?>');
		cnt.focus();
		return;
	}

	var cnt = document.GoodsRecord.Content;
	if(!(cnt.value == '') && !alpha(cnt) && !confirm('领取内容不能为空')) {
		cnt.focus();
		return;
	} else if (cnt.value == '') {
		alert('<?php echo $lang_Error_FirstNameEmpty?>');
		cnt.focus();
		return;
	}*/



	//document.GoodsRecord.sqlState.value = "NewRecord";
	document.standardView.submit();
}
	function clear_form() {
		document.standardView.loc_code.options[0].selected=true;
		document.standardView.loc_name.value='';
	}
	YAHOO.OrangeHRM.container.init();
	function formcheck(){
		alert("dfdf");
		var EmpName = document.getElementById('EmpName').value;
		var Content = document.getElementById('Content').value;
		var StartTime = document.getElementById('StartTime').value;
		var endTime = document.getElementById('EndTime').value;
		var holiday = parseFloat(document.getElementById('holiday').innerHTML);
		var hour = document.getElementById('hour').value;
		var obj = document.getElementById('AdType');
	    var type = obj.options[obj.selectedIndex].value;
		
		if(EmpName == ''){
			alert("员工名字不能为空，你请确认是员工");
			return false;
		}
		if(Content == ''){
			alert("申请原因不能为空");
			return false;
		}
		if(StartTime == ''){
			alert("开始不能为空");
			return false;
		}
		if(endTime == ''){
			alert("结束时间不能为空");
			return false;
		}
		if(hour == ''){
			alert("时长不能为空");
			return false;
		}
		
		//判断年假是否足够
		if(type == 3){
			if(holiday == 0){
				alert("抱歉，你的年假已经用完或超过有效期了！");
				return false;
			}else if(holiday < hour){
				alert("抱歉，你的年假不够本次请假的小时数！");
				return false;
			}
		}
		
	}
</script>
<style>
.shownameclass{float:left;width:370px;height:150px;position: absolute;z-index:5000;background-color:#ffffff;left:70px;border:1px solid #ccc;overflow:auto;}
</style>
<body class="yui-skin-sam">
<div class="formpage2col">
<form name="standardView" id="standardView" method="post" action="<?php echo $_SERVER['PHP_SELF']?>?adcode=special_attend&action=save" onsubmit="return formcheck()>
	<div class="outerbox">
		<div class="mainHeading"><h2>添加特殊考勤</h2></div>
		<div style="padding:10px;font-size:14px;">你的年假剩余小时数：<font color=red><span id="holiday"><?php echo $records['ResidualHours']['jiaqi'];?></span></font>小时,有效期：
		<?php echo $records['ResidualHours']['EffectDate']."~".$records['ResidualHours']['EndDate'];?></div>
		<input type="hidden" name="Id" id="Id" value="<?php echo isset($records['Id']) ? $records['Id']:'';?>" />
		<input type="hidden" name="Id" id="Id" value="<?php echo isset($records['Id']) ? $records['Id']:'';?>" />
		<input type="hidden" name="EmpId" id="EmpId" value="<?php echo isset($records['EmpId']) ? $records['EmpId']:'';?>" />

		<label for="txtEmpLastName">员工名字 <span class="required">*</span></label>
		<input type="text" name="EmpName" id="EmpName" class="formInputText" 
			value="<?php echo isset($records['emp_firstname']) ? $records['emp_firstname']:'';?>" onblur="GetEmpListName('<?php echo $_SERVER['PHP_SELF']?>?adcode=GetEmpName','tbname','EmpName','ShowEmpName','EmpId')"/><br>
		<div id="ShowEmpName" class="shownameclass" style="display:none"><table id="tbname" width="350" border="0" cellspacing="0" cellpadding="0"></table></div>
		<br class="clear" />
		
		<label for="txtAdType" id="txtAdType">考勤类型 <span class="required">*</span></label>
		<select name="AdType" id="AdType" class="formSelect"> 
			<?php foreach ($records['typelist'] as $key => $val) {?>
			<option value="<?php echo $key;?>" <?php if($records['TypeId'] == $key || $_REQUEST['typeid'] == $key) echo "selected=true";?>><?php echo $val;?></option>
			<?php } ?>
		</select>
		<br class="clear" />
		<label for="txtEmpFirstName" id="txtEmpFirstName">申请原因 <span class="required">*</span></label>
		<textarea name="Content" id="Content" class="formInputText"  style="margin-left:10px;width:270px;height:100px;"
			 /><?php echo (isset($records['Content']))?$records['Content']:''?></textarea>
		
		<!--<br class="clear" />
		 <input name="txtDate" id="txtDate" type="text" value="<?php echo LocaleUtil::getInstance()->formatDate($date); ?>"
            class="formDateInput" />
        <input type="button" name="Submit" value="  " class="calendarBtn" /></td>-->
        <br class="clear" />
		<label for="txtEmpFirstName" id="txtEmpFirstName">开始时间 <span class="required">*</span></label>
		<input type="text" readonly name="StartTime" id="StartTime" class="formInputText" 
			value="<?php echo isset($records['StartTime']) ? @date('Y-m-d',$records['StartTime']):@date('Y-m-d');?>"/>
			<input type="button" class="calendarBtn" value="" name="Submit">
            <select name="StartTime_hour" class="formSelect" style="width:50px;">
            <?PHP 
			for($i=0;$i<24;$i++){
				if(!empty($records['StartTime']) && date('H',$records['StartTime']) == $i){
					echo "<option value=\"".$i."\"  selected=\"selected\">".$i."时</option>";
				}else{
					echo "<option value=\"".$i."\">".$i."时</option>";
				}
			}
			?>
            </select>
            <select name="StartTime_min" class="formSelect" style="width:50px;">
            <?PHP 
			for($j=0;$j<61;$j++){
				if($j % 5 ==0){
					if(!empty($records['StartTime']) && date('i',$records['StartTime']) == $j){
						echo "<option value=\"".$j."\" selected=\"selected\">".$j."分</option>";
					}else{
						echo "<option value=\"".$j."\">".$j."分</option>";
					}
				}
			}
			?>
            </select>
		<br class="clear" />

		<label for="txtEmpMiddleName">结束时间</label>
		<input type="text" readonly name="EndTime" id="EndTime" class="formInputText"  value="<?php echo isset($records['EndTime']) ? @date('Y-m-d',$records['EndTime']):'';?>"/>
		<input type="button" class="calendarBtn" value="" name="Submit">
        <select name="EndTime_hour" class="formSelect" style="width:50px;">
            <?PHP 
			for($i=0;$i<24;$i++){
				if(!empty($records['EndTime']) && date('H',$records['EndTime']) == $i){
					echo "<option value=\"".$i."\"  selected=\"selected\">".$i."时</option>";
				}else{
					echo "<option value=\"".$i."\">".$i."时</option>";
				}
			}
			?>
            </select>
            
            <select name="EndTime_min" class="formSelect" style="width:50px;">
            <?PHP 
			for($j=0;$j<61;$j++){
				if($j % 5 ==0){
					if(!empty($records['EndTime']) && date('i',$records['EndTime']) == $j){
						echo "<option value=\"".$j."\" selected=\"selected\">".$j."分</option>";
					}else{
						echo "<option value=\"".$j."\">".$j."分</option>";
					}
				}
			}
			?>
            </select>
		<br class="clear"/>
		<label for="txtEmpMiddleName">时长（小时）：<span class="required">*</span></label>
		<input type="text" name="hour" id="hour" class="formInputText"  value="<?php echo $records['hour'];?>"/>
        <span style="line-height:32px;">小时</span>
        <br class="clear"/>
		<?php  if(isset($records['Id']) && $records['Id'] > 0) { ?>
		<label for="txtEmpMiddleName">添加时间</label>
		<label class="formInputText"><?php echo isset($records['AddTime']) ? @date("Y-m-d H:i:s",$records['AddTime']):'';?></label>
		<br class="clear"/>
		<?php } ?>
		<div style="padding:2px 5px;line-height:20px;color:#F00;">提示：
        <br class="clear"/>1、时长填写为你的总小时数，一天为8个小时，多少天填写天数×8小时,如2天为2×8=16小时，即时长为16小时；
        <br class="clear"/>2、一天的开始时间是上班时间，结束时间是下班时间，多天的为第一天的上班时间到最后一天下班时间；
        <br class="clear"/>3、年假审批通过才会扣除，一天为8小时</div>
		<br class="clear"/>
        <div class="formbuttons">
			<input type="submit" class="savebutton" id="btnEdit" 
				onmouseover="moverButton(this);" onmouseout="moutButton(this);"
				value="<?php echo $lang_Common_Save;?>" title="<?php echo $lang_Common_Save;?>" />
			<input type="button" class="resetbutton" onclick="document.GoodsRecord.reset(); return false;"
				onmouseover="moverButton(this);" onmouseout="moutButton(this);"
				 value="<?php echo $lang_Common_Reset;?>" />
        </div>
	</div>
	<div class="requirednotice"><?php echo preg_replace('/#star/', '<span class="required">*</span>', $lang_Commn_RequiredFieldMark); ?>.</div>
	</form>
</div>
<div id="cal1Container" style="position:absolute;" ></div>
<script type="text/javascript">
//<![CDATA[
    if (document.getElementById && document.createElement) {
        roundBorder('outerbox');
    }
//]]>
</script>
</body>
